<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/search.css') ?>
<?php
$isSearchForm = !empty($this->searchForm);
if ($isSearchForm && method_exists($this->searchForm, 'hasAttributes')) {
    $isSearchForm = $this->searchForm->hasAttributes();
}
?>
<div class="search">
    <?php if (!$isSearchForm): ?>
    <form class="form-search clearfix" action="/search/<?= isset($this->actionName) ? $this->actionName : "index" ?>" method="get">
        <div class="input-append span12">
            <input type="text" class="span10 search-query" name="q" value="<?= htmlspecialchars(My_Utils::getRequestParam('q')) ?>" placeholder="<?= isset($this->placeholder) ? $this->placeholder : '' ?>">
            <button type="submit" class="btn">Szukaj</button>
            <?php if (isset($this->searchCode)): ?>
                <input type="hidden" name="id" value="<?= $this->searchCode ?>"/>
            <?php endif; ?>
        </div>
        <?php if ($isSearchForm): ?>
            <a class="search-adv-activator" href="#">Wyszukiwanie zaawansowane</a>
        <?php endif ?>
    </form>
    <?php endif; ?>
    <?php if ($isSearchForm): ?>
        <div class="search-advanced">
            <?= $this->searchForm ?>
        </div>
    <?php endif ?>
</div>
<?php if (false && $isSearchForm): ?>
    <script type="text/javascript">
        $(function() {
            $('div.search form.offer-search-form').submit(function(event) {
                var q = $('div.search form.form-search .search-query').val();
                $('form.offer-search-form #q').val(q);
            });
            $('.search .search-adv-activator, .search .form-cancel').click(function(event) {
                event.preventDefault();
                $('.search .search-advanced').slideToggle();
                return false;
            });
        });
    </script>
    <style type="text/css">
        .search .form-search {
            margin-bottom: 0px;
        }
    </style>
    <?php
 endif ?>
